﻿// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

Shader "YYTest/sCmdTestNew"
{
	Properties
	{
		//_MainTex ("Texture", 2D) = "white" {}
	}
	CGINCLUDE
#include "UnityCG.cginc"

	struct appdata
	{
		float4 vertex : POSITION;
		float2 uv : TEXCOORD0;
	};

	struct v2f
	{
		float2 uv : TEXCOORD0;

		float4 vertex : SV_POSITION;
	};

	sampler2D _MainTex;
	float4 _MainTex_ST;

	// Vertex manipulation
	float2 TransformTriangleVertexToUV(float2 vertex)
	{
		float2 uv = (vertex + 1.0) * 0.5;
		return uv;
	}


	v2f vertNew(appdata v)
	{
		v2f o;
		//o.vertex = UnityObjectToClipPos(v.vertex);
		//o.uv = TRANSFORM_TEX(v.uv, _MainTex);
		o.vertex = float4(v.vertex.xy, 0.0, 1.0);
		//o.uv = TRANSFORM_TEX(v.uv, _MainTex);

		o.uv = TransformTriangleVertexToUV(v.vertex.xy);

#if UNITY_UV_STARTS_AT_TOP
		o.uv = o.uv * float2(1.0, -1.0) + float2(0.0, 1.0);
#endif



		return o;
	}

	fixed4 frag(v2f i) : SV_Target
	{
		// sample the texture
		fixed4 col = tex2D(_MainTex, i.uv);
		return col;
		//return fixed4(1, 0, 0, 0);
		//return fixed4(1, col.g, col.b, col.a);
	}
	ENDCG

	SubShader
	{
		Tags { "RenderType" = "Opaque" }
		LOD 100

		cull off

		Pass
		{
			CGPROGRAM
			#pragma vertex vertNew
			#pragma fragment frag
			ENDCG
		}
	}
	
}
